/**
 * @file
 * @auth jinguangguo
 * @date 2017/1/18
 */

import Vue from 'vue';
import tpl from './tpl.html';
import commonService from '../../../common/commonService';
import service from './service'
import filter from '../../../../grsc-base/util/filter';
import lib from '../../../common/lib';
import Popover from '../../../../grsc-base/component/Popover.vue';
import Loading from '../../../../grsc-base/component/Loading.vue';
import NoData from '../../../../grsc-base/component/NoData.vue';
import Pager from '../../../../grsc-base/component/Pager.vue';
import MathTool from '../../../../grsc-base/util/mathtool';

export default Vue.extend({
    name: "LockReward",
    template: tpl,
    components: {
        Popover,
        Loading,
        NoData,
        Pager
    },

    data() {
        return {
            filter: filter,
            coinTypeText: 'ACT',
            precision: 0,

            lockRewardList: [],
            isLockRewardListLoading: true,
            condition: {
                pageNo: 1,
                pageSize: 10,
                pageNum: 1
            }
        }
    },
    created() {
        this.fetchLockRewardList();
    },
    mounted(){
    },
    methods: {

        /**
         * 获取锁仓奖励记录
         * */
        fetchLockRewardList(){
            this.isLockRewardListLoading = true;
            let param = {
                assetCode: this.coinTypeText,
                pageNo: this.condition.pageNo,
                pageSize: this.condition.pageSize
            };
            service.lockRewardList(param).done((rep) => {
                if (rep.code === window.CODE.SUCCESS) {
                    this.lockRewardList = rep.data.list;
                    this.condition.pageNum = Number(filter.ceilFix(rep.data.total / this.condition.pageSize, 0));
                } else {
                    window.error(rep.msg)
                }
                this.isLockRewardListLoading = false;
            })
        },

        /**
         * 分页change
         * @param currentPage
         */
        changePage(currentPage) {
            this.condition.pageNo = currentPage;
            this.fetchLockRewardList();
        }

    },
    watch: {}
});
